export namespace main {
	
	export class Table {
	    tablename: string;
	    comment?: string;
	    collation?: string;
	
	    static createFrom(source: any = {}) {
	        return new Table(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.tablename = source["tablename"];
	        this.comment = source["comment"];
	        this.collation = source["collation"];
	    }
	}
	export class CompareResult {
	    ok: boolean;
	    message: string;
	    addTables: Table[];
	    deleteTables: Table[];
	    modifiedTables: Table[];
	    unChangedTables: Table[];
	
	    static createFrom(source: any = {}) {
	        return new CompareResult(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.ok = source["ok"];
	        this.message = source["message"];
	        this.addTables = this.convertValues(source["addTables"], Table);
	        this.deleteTables = this.convertValues(source["deleteTables"], Table);
	        this.modifiedTables = this.convertValues(source["modifiedTables"], Table);
	        this.unChangedTables = this.convertValues(source["unChangedTables"], Table);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Datasource {
	    id: string;
	    type: string;
	    name: string;
	    port: number;
	    host: string;
	    username: string;
	    password: string;
	    database: string;
	
	    static createFrom(source: any = {}) {
	        return new Datasource(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.id = source["id"];
	        this.type = source["type"];
	        this.name = source["name"];
	        this.port = source["port"];
	        this.host = source["host"];
	        this.username = source["username"];
	        this.password = source["password"];
	        this.database = source["database"];
	    }
	}
	export class SyncInput {
	    from: Datasource;
	    to: Datasource;
	
	    static createFrom(source: any = {}) {
	        return new SyncInput(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.from = this.convertValues(source["from"], Datasource);
	        this.to = this.convertValues(source["to"], Datasource);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}

}

